package com.aatattoo.light_food_service.service;

import com.aatattoo.light_food_service.entity.*;
import com.aatattoo.light_food_service.mapper.FoodMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
@Component
public class FoodService {

    @Autowired
    private FoodMapper foodMapper;

    //根据类型查询相应的食物
    public List<Food> selectFoodByType(int type){
        return foodMapper.selectFoodByType(type);
    }
    //查询食物详情
    public Food selectFooDetails(int id){
        return foodMapper.selectFooDetails(id);
    }
    //根据食物id查询跟食物相关的食谱
    public List<Recipes> selectCookFoodByFoodId(int id){
        return foodMapper.selectCookFoodByFoodId(id);
    }
    //根据食物id查询食物好坏处
    public List<GoodUse> selectGoodUseByFoodId(int id){
        return foodMapper.selectGoodUseByFoodId(id);
    }
    //根据食谱id查询食谱
    public Recipes selectRecipesById(int id){
        return foodMapper.selectRecipesById(id);
    }
    //根据食谱id查询食物做法用量
    public List<Meterials> selectMeterials(int id){
        return foodMapper.selectMeterials(id);
    }
    //收藏食物
    public int insertCollect(Collect collect){
        return foodMapper.insertCollect(collect);
    }

    public  int countCollect(Collect collect){
        return foodMapper.countCollect(collect);
    }

    public int checkCollect(Collect collect){
        return foodMapper.checkCollect(collect);
    }

    //取消收藏
    public int deleteCollect(Collect collect){
        return foodMapper.deleteCollect(collect);
    }
    //查询是否收藏
    public int inCollect(Collect collect){
        return foodMapper.inCollect(collect);
    }
    //食谱收藏的数量
    public int collectCount(Collect collect){
        return foodMapper.collectCount(collect);
    }
    //查找营养素的信息
    public List<Trophic> getTrophic(){
        return foodMapper.getTrophic();
    }
    //查找不建议搭配的信息
    public List<Common> getCommon(){
        return foodMapper.getCommon();
    }
    //查找收藏列表
    public List<Collect> getCollect(Collect collect) {
        return foodMapper.getCollect(collect);
    }
    //食谱收藏列表
    public Recipes getRecipes(int id){
        return foodMapper.getRecipes(id);
    }
    //查找动态收藏表
    public Dynamic getDynamic(int id){
        return foodMapper.getDynamic(id);
    }
    //查找动态第一张图片
    public DynamicImg getFirstImg(DynamicImg dynamicImg){
        return foodMapper.getFirstImg(dynamicImg);
    }
    //添加浏览记录
    public int addRecording(Recording recording){
        return foodMapper.addRecording(recording);
    }
    //查询浏览记录是否存在
    public int inRecording(Recording recording){
        return foodMapper.inRecording(recording);
    }
    //更新浏览记录
    public int upRecording(Recording recording){
        return foodMapper.upRecording(recording);
    }
    //查询浏览记录列表   食物
    public Food selectRecordingFood(int id){
        return foodMapper.selectRecordingFood(id);
    }
    //查询食物浏览记录列表  食谱
    public Recipes selectRecordingRecipes(int id){
        return foodMapper.selectRecordingRecipes(id);
    }
    //查询浏览内容的id
    public List<Recording> selectId(Recording recording){
        return foodMapper.selectId(recording);
    }
    //搜索
    public List<Food> searchFood(String name){
        return foodMapper.searchFood(name);
    }
    //搜索食谱
    public List<Recipes> searchRecipes(String name){
        return foodMapper.searchRecipes(name);
    }
    //查询全部食谱
    public List<Recipes> allRecipes(){
        return foodMapper.allRecipes();
    }

    /**
     * 查询全部食物在controller里面进行根据类型排序查询
     * @return
     */
    public List<Food> allFood(){
        return foodMapper.allFood();
    }

    //推荐食谱，写死了的
    public List<Recipes> newsRecipes (ArrayList<Integer> idList){
        return foodMapper.newsRecipes(idList);
    }
}
